@echo off

echo "本文读取当前路径，对于有空格的路径，进行加""处理 "

call::format_dir

pause

:format_dir
set count=0
set r=
set subr=
set str="%CD%"
:STR_VISTOR
echo "-----------------start-----------------"
echo str = %str%
for /f "tokens=1,* delims=\" %%a in (%str%) do (
   set str="%%b"
   echo str="%str%"
   echo a=%%a
   set "sa=%%a"
   
   set count=%count%+1
   ::REM 判断是否是第一个字符串
   if '%r%'=='' (
        set r=%%a
		echo "First"
    ) else (
		echo "Second"
        ::REM 判断是否有空格
		echo sa=%%a
		echo;%%a|find " "&&(
			echo "Has"
			::REM 有空格时，添加 ""	
			set r=%r%/"%%a"
		) || (
			echo "Not"
			::REM 没有空格时，不添加 “”
			set r=%r%/%%a
		)
    ) 
   echo r=%r%
   echo ""
   goto STR_VISTOR
)
echo result=%r%


@echo off
REM 判断是否有空格
set "a=S5 项目"
set has=false
rem echo;%a%|findstr /c:" "&&echo;ture || echo;false
echo;%a%|find " "&&(set has=true ) || (set has=false)
echo "has=%has%"
pause
